<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/22
 * Time: 19:40
 */
class 防止外部提交表单禁止跨站提交
{

}
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
$host = $_SERVER['HTTP_HOST'];
echo '提交过来的地址：'.$referer;
echo '<br>';
echo '本站域名：'.$host;
echo '<br>';
echo substr($referer,7,strlen($host));
if(substr($referer,7,strlen($host)) != $host){
    echo '非法操作';
}else{
    echo '正常操作';
}